######## CONFLICT OUTCOMES ##########

outcome = "prog_indben"  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm1 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~ period_new + villageid,
                       se_type = "stata", data = reds_rand, clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm2 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.st.matched, clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vscstreserv_prior + prop_ST91"
  reds.lm3 = lm_robust(paste(outcome, "~ vwreserv*vscstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.scst.matched, clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm4 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~period_new + villageid,
                       se_type = "stata", data = reds_rand %>% filter(fem==1), clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm5 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.st.matched %>% filter(fem==1), clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vscstreserv_prior + prop_ST91"
  reds.lm6 = lm_robust(paste(outcome, "~ vwreserv*vscstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.scst.matched %>% filter(fem==1), clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm7 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~period_new + villageid,
                       se_type = "stata", data = reds_rand %>% filter(fem==1 & Caste_ST==1), clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vstreserv_prior + prop_ST91"
  reds.lm8 = lm_robust(paste(outcome, "~ vwreserv*vstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.st.matched %>% filter(fem==1 & Caste_ST==1), clusters = villageid) 
  
  controls = "top20land + birthyr + fem + Caste_ST + Caste_SC + vwreserv_prior + vscstreserv_prior + prop_ST91"
  reds.lm9 = lm_robust(paste(outcome, "~ vwreserv*vscstreserv", "+", controls) %>% as.formula(),
                       fixed_effects = ~districtid + period_new, se_type = "stata",
                       data = reds.scst.matched %>% filter(fem==1 & (Caste_ST==1 | Caste_SC==1)), clusters = villageid) 
  
  
  
  
  dv.means =  c(round(mean(reds_rand$prog_indben, na.rm = T), 3),
                round(mean(reds.st.matched$prog_indben, na.rm = T), 3),
                round(mean(reds.scst.matched$prog_indben, na.rm = T), 3),
                round(mean(reds_rand$prog_indben[reds_rand$fem==1], na.rm = T), 3),
                round(mean(reds.st.matched$prog_indben[reds.st.matched$fem==1], na.rm = T), 3),
                round(mean(reds.scst.matched$prog_indben[reds.scst.matched$fem==1], na.rm = T), 3),
                round(mean(reds_rand$prog_indben[reds_rand$fem==1&reds_rand$Caste_ST==1], na.rm = T), 3),
                round(mean(reds.st.matched$prog_indben[reds.st.matched$fem==1&reds.st.matched$Caste_ST==1], na.rm = T), 3),
                round(mean(reds.scst.matched$prog_indben[reds.scst.matched$fem==1&(reds.scst.matched$Caste_ST==1|reds.scst.matched$Caste_SC==1)], na.rm = T), 3))
  
  
 
  screenreg(l = list(reds.lm1, reds.lm2, reds.lm3, 
                     reds.lm4, reds.lm5, reds.lm6, 
                     reds.lm7, reds.lm8, reds.lm9), include.ci = F, include.rmse = F,
            include.nobs = T,include.adjrs = FALSE, include.rsquared = F,
            digits = 3, include.nclust = F,
            omit.coef = c("Intercept|top20land|birthyr|prop_ST91|fem|Caste_ST|Caste_SC|vwreserv_gp12|vstreserv_gp12|prop_STnow|vscstreserv_gp12|prop_SCnow|vwreserv_prior|vstreserv_prior|vscstreserv_prior"),
            custom.coef.names = c("Women's Quota", "Caste Quota (ST)", "W X C (ST) Quota", 
                                  "Caste Quota (ST/SC)", "W X Caste (ST/SC) Quota"),
            stars = c(0.01, 0.05, 0.1),
            custom.model.names = c("All", "All", "All", "Women", "Women",
                                   "Women", "ST Women", "ST Women", "ST Women"),
            custom.gof.rows = list(
              "Caste Quota Type" = c("ST", "ST", "ST/SC", "ST", "ST", "ST/SC", "ST", "ST", "ST/SC"),
              "DV Mean" = dv.means,
              "Controls" = c("Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"),
              "Village FE" = c("Yes", "No", "No", "Yes", "No", "No", "Yes", "No", "No"),
              "Period FE" = c("Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"),
              "District FE" = c("No", "Yes", "Yes", "No", "Yes", "Yes", "No", "Yes", "Yes"),
              "Matched Data" = c("No", "Yes", "Yes", "No", "Yes", "Yes", "No", "Yes", "Yes")), 
            file = paste0(tab.out, "tableL24.tex"))  
  

